package dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import utilClasses.ListaKlijentPodaci;
import utilClasses.uKlijentPodaci;

public class daoAndrKlijent {
	public static ListaKlijentPodaci dajLinije(double sirina, double duzina) throws SQLException 
	{
		ListaKlijentPodaci rez=new ListaKlijentPodaci();
		Connection c=null;
		try {
			c=daoKonekcija.dajKonekciju();
			CallableStatement cStmt = c.prepareCall("{CALL dajLinijeBlizu(?,?)}");
			cStmt.setDouble(1, sirina );//17.668
			cStmt.setDouble(2, duzina );//43.738
			ResultSet rs=cStmt.executeQuery();
			while(rs.next())
			{
				String nLinije=rs.getString(1);
				String nStanice=rs.getString(2);
				String nPrevoznik=rs.getString(3);
				double cijena=rs.getDouble(4);
				double udaljenost=rs.getDouble(5);
				rez.getPodaci().add(new uKlijentPodaci(nLinije, nPrevoznik, nStanice, udaljenost, cijena));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally
		{
			if(c!=null)c.close();
		}
		
		return rez;
		
	}

}
